package com.mux.springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mux.springboot.config.AuthorSettings;
import com.mux.springboot.config.ParamProperties;

@Controller
public class ConfigController {
	
	@Autowired
	private AuthorSettings authorSettings;
	
	@Autowired
	private ParamProperties paramProperties;
	
	@Autowired
	Environment env;
	
	
	@RequestMapping("/getInfo")
	@ResponseBody
	public String index(){
		return authorSettings.getName()+""+ authorSettings.getAge();
	}
	
	@RequestMapping("/getParam")
	@ResponseBody
	public String getParam(){
		return paramProperties.getName()+" "+paramProperties.getAge();
	}
	
	@GetMapping("/getParamByEnv")
	@ResponseBody 
	public String getParamByEnv(){
		return env.getProperty("param.name") +" " +env.getProperty("param.age") 
		+ "  "+ env.getProperty("param.desc");
	}
	
	
	@GetMapping("/getAllParam")
	@ResponseBody 
	public String getAllParam(){
		return env.getProperty("param.name") +" " +env.getProperty("param.age")+";"
				+env.getProperty("author.name")+" "+env.getProperty("author.age");
	}
	
}
